package com.leetcode.LC;

public class LC868 {
    public int binaryGap(int n) {

        String s = Integer.toBinaryString(n);
        int count = 0;
        String tmp = "11";

        for (int i = 0; i <s.length(); i++) {
            if (s.contains(tmp)) {
                count = tmp.length()-1;
            }
            tmp=tmp.substring(0,tmp.length()-1)+"01";
        }
        return count;
    }

    public static void main(String[] args) {
        System.out.println(new LC868().binaryGap(22));
    }
}
